<?php

namespace app\exam\validate;

use think\Validate;

/**
 * 公开考试练习验证
 */
class Examination extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'module_id'     => 'require|number',
        'category'      => 'number',
        'title'         => 'require',
        'paper_id'      => 'require|number',
        'record_id'     => 'require|number',
        'epar_id'       => 'require|number',
        'part_id'       => 'require|number',
        'topic_id'      => 'require|number',
        'unique_code'   => 'require|/^[\w]+$/',

    ];

    protected $field = [
        'module_id'     => '版块',
        'title'         => '名称',
        'category'      => '分类',
        'paper_id'      => '试卷',
        'record_id'     => '考试记录',
        'epar_id'       => '考试记录',
        'part_id'       => '部分',
        'topic_id'      => '试题',
        'unique_code'   => '唯一标识',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'examination_list'      => ['module_id', 'category'],
        'examination_search'    => ['module_id', 'title'],
        'examination_record'    => ['record_id'],
        'topic_record'          => ['unique_code', 'epar_id', 'part_id', 'topic_id'],
    ];


}
